fix(redirect): fd3 redirection pattern 3>&1 >file now routes correctly#1139
Merged
fix(redirect): fd3 redirection pattern 3>&1 >file now routes correctly#1139
Conversation
ef930ba to
e00d366
Compare
Use interpreter-level pending_fd_output buffer to carry fd3+ content from inner 1>&N redirects to compound-level fd-table routing. Changes: - Interpreter.pending_fd_output: buffer for fd3+ output - apply_redirections fast path: 1>&N (N>=3) moves stdout to pending buffer - apply_redirections_fd_table: supports fd3+ via extra_fd_targets + pending - route_fd_table_content: extracted non-async helper to avoid state machine bloat Closes #1115
e00d366 to
215b591
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
{ echo msg 1>&3; echo data; } 3>&1 >filepattern where fd3 content ended up in file instead of original stdoutextra_fdsfield toExecResultfor carrying fd3+ content through execution layersapply_redirections_fd_tablefrom hardcoded fd1/fd2 to HashMap-based arbitrary fd supportWhat
The fd-table redirect model only tracked fd1 (stdout) and fd2 (stderr). When
3>&1 >filewas used on a compound command, the3>&1dup was silently ignored because fd3 had no slot in the table. Content written to fd3 via inner1>&3redirects was lost.How
extra_fds: HashMap<i32, String>toExecResult— carries content written to fd3+ via inner redirectsapply_redirectionsfast path:1>&N(N>=3) moves stdout toextra_fds[N]apply_redirections_fd_tableto use aHashMap<i32, FdTarget>instead of separatefd1/fd2variables, supporting arbitrary fd numbersexecute_listandexecute_command_sequence_implto accumulateextra_fdsfrom sub-commandsTests
test_fd3_redirect_patternverifying the full3>&1 >filepatternfd3_redirect_patterninexec-fd-redirect.test.shCloses #1115